package com.irdstudio.efp.esb.api.service.yed.customer;

import com.irdstudio.basic.framework.core.base.FrameworkService;
import com.irdstudio.basic.framework.core.constant.EsbRetCodeStandard;
import com.irdstudio.basic.framework.core.constant.SDicToLocalConstant;
import com.irdstudio.basic.framework.core.exception.ESBException;
import com.irdstudio.basic.framework.core.util.SpringContextUtils;
import com.irdstudio.basic.framework.core.util.sdic.SDicToLocal;
import com.irdstudio.basic.sequence.service.facade.SequenceService;

import com.irdstudio.efp.console.common.YedEnums;
import com.irdstudio.efp.cus.service.facade.CusIndivRelService;
import com.irdstudio.efp.cus.service.facade.CusIndivService;
import com.irdstudio.efp.cus.service.vo.CusIndivRelVO;
import com.irdstudio.efp.cus.service.vo.CusIndivVO;
import com.irdstudio.efp.esb.api.bean.yed.req.ReqYedCustomerCollectionBean;
import com.irdstudio.efp.esb.api.common.EsbRespServiceHandler;
import com.irdstudio.efp.esb.common.server.req.EsbReqServiceBean;
import com.irdstudio.efp.esb.common.server.resp.EsbRespServiceBean;
import com.irdstudio.efp.esb.service.bo.req.yed.customer.ReqYedCusToOnlineFinanceBean;
import com.irdstudio.efp.esb.service.facade.sed.customer.CustomerCollectionService;
import com.irdstudio.efp.esb.service.facade.yed.customer.YedCustomerCollectionService;
import com.irdstudio.efp.limit.service.facade.LmtPrdContService;
import com.irdstudio.efp.limit.service.vo.LmtPrdContVO;
import com.irdstudio.efp.nls.service.facade.NlsApplyRelationService;
import com.irdstudio.efp.nls.service.facade.sx.NlsCreditInfoService;
import com.irdstudio.efp.nls.service.vo.NlsApplyRelationVO;
import com.irdstudio.efp.nls.service.vo.sx.NlsCreditInfoVO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
import java.util.Optional;

/**
* 优e贷产品对税e贷产品的此部分代码做了复用
* 说明：为了保证功能的复用性、提升开发的工作效率，对该代码进行了复用
* 评估是否会影响线上功能：否
* 评估时间：
* 处理方案：保留复用
*/

/**
 * 需求编号:2019D0519
 * 问题编号:
 * 开发人员: caoxin
 * 创建日期:2019/7/17
 * 功能描述:客户补录服务接口
 * 修改日期:2019/7/17
 * 修改描述:
 */
@Service("yedNlsCustomerProcessService")
public class YedNlsCustomerProcessService implements FrameworkService {
    /**
     * 客人信息补录主流程: <br>
     * <p>
     * 0.1:caoxin:2019/4/19 8:21: <br>
     * @return
     * @author caoxin
     * @date 2019/4/19 8:21
     * @version 0.1
     * @since 2019/4/19 8:21
     */

    public EsbRespServiceBean processCustomerCollection(EsbReqServiceBean esbReqServiceBean, ReqYedCustomerCollectionBean reqYedCustomerCollectionBean) throws Exception {
        // 客户信息补录校验--获取授信申请
        NlsCreditInfoVO nlsCreditInfoVO = validateCustomerCollection(reqYedCustomerCollectionBean);
        //查询出客户信息
        final CusIndivVO param = new CusIndivVO();
        param.setCusId(reqYedCustomerCollectionBean.getKeyCusNumber());
        final CusIndivVO cusIndivVO = cusIndivService.queryByPk(param);
        if (Objects.isNull(cusIndivVO)) {
            throw new ESBException(EsbRetCodeStandard.WFJKYWGZ.getValue(), "查询到的客户信息为空!!!");
        }

        // 设置请求对象属性
        ReqYedCusToOnlineFinanceBean reqYedCusToOnlineFinanceBean = getReqSedCusToOnlineFinanceBean(reqYedCustomerCollectionBean,nlsCreditInfoVO);
        reqYedCusToOnlineFinanceBean.setClntNo(cusIndivVO.getInnerCusId());
        // 调用互金客户补录
        yedCustomerCollectionService.pushCustomerInfoToOnlineFinance(reqYedCusToOnlineFinanceBean,esbReqServiceBean.getSysHead().getGlblSrlNo());
        /**
         * 成功后根据互金核心返回结果更新
         *【授信申请表】
         *【客人表】
         *【新增授信联系人表】
         *【授信协议表信息】
         * */
        updateCustomerInfoOnCreditApplyAndCustomer(reqYedCustomerCollectionBean);

        return EsbRespServiceHandler.esbSuccessHandler(esbReqServiceBean);
    }

    /****************************************************************************************************/
    /*********************************** 校验 ***********************************************************/
    /****************************************************************************************************/
    /**
     * 客户信息补录信息校验: <br>
     * 0.1:caoxin:2019/6/24 19:17: 客户信息补录信息校验: <br>
     * @author caoxin
     * @return 
     * @since 2019/6/24 19:17
     * @date 2019/6/24 19:17
     * @version 0.1
     */
    
    private NlsCreditInfoVO validateCustomerCollection(ReqYedCustomerCollectionBean reqYedCustomerCollectionBean) throws ESBException {
        // 校验该用户是否有存在授信申请
        NlsCreditInfoVO nlsCreditInfoVO = nlsCreditInfoService.queryByLmtApplySeq(reqYedCustomerCollectionBean.getLmtApplySeq());
        if (nlsCreditInfoVO == null) {
            throw new ESBException(EsbRetCodeStandard.WFJKYWGZ.getValue(), "该授信申请不存在,客户补录失败!!!");
        }
        return nlsCreditInfoVO;
    }
    /****************************************************************************************************/
    /*********************************** 更新 ***********************************************************/
    /****************************************************************************************************/
    /**
     * 设置请求对象属性: <br>
     * <p>
     * 0.1:caoxin:2019/5/24 17:46: <br>
     * @return
     * @author caoxin
     * @date 2019/5/24 17:46
     * @version 0.1
     * @since 2019/5/24 17:46
     */
    private ReqYedCusToOnlineFinanceBean getReqSedCusToOnlineFinanceBean(ReqYedCustomerCollectionBean reqYedCustomerCollectionBean, NlsCreditInfoVO nlsCreditInfoVO) {
        // 推送数据到互金核心进行补录
        ReqYedCusToOnlineFinanceBean reqYedCusToOnlineFinanceBean = new ReqYedCusToOnlineFinanceBean();
        // 来源客户信息补录接口 客户ID
        reqYedCusToOnlineFinanceBean.setClntNo(reqYedCustomerCollectionBean.getKeyCusNumber());
        // 来源客户信息补录接口 客户姓名
        reqYedCusToOnlineFinanceBean.setCustNm(reqYedCustomerCollectionBean.getCusName());
        // 来源客户信息补录接口 客户证件号
        reqYedCusToOnlineFinanceBean.setCertNo(reqYedCustomerCollectionBean.getCertCode());
        // 来源客户信息补录接口 证件类型
        reqYedCusToOnlineFinanceBean.setCertTp(reqYedCustomerCollectionBean.getCertTp());
        // 来源客户信息补录接口 证件到期日
        if (StringUtils.isNotEmpty(reqYedCustomerCollectionBean.getIndivIdExpDt())) {
            reqYedCusToOnlineFinanceBean.setIdenEfftDt(LocalDate.parse(reqYedCustomerCollectionBean.getIndivIdExpDt(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).format(DateTimeFormatter.ofPattern("yyyyMMdd")));
        }
        // 来源客户信息补录接口 手机
        reqYedCusToOnlineFinanceBean.setMblNo(reqYedCustomerCollectionBean.getPhone());
        // 来源客户信息补录接口 婚姻状况
        reqYedCusToOnlineFinanceBean.setMrgSitu(StringUtils.isEmpty(reqYedCustomerCollectionBean.getIndivMarSt())?nlsCreditInfoVO.getMrgSitu():reqYedCustomerCollectionBean.getIndivMarSt());
        // 来源客户信息补录接口 最高学位
        reqYedCusToOnlineFinanceBean.setEduCd(reqYedCustomerCollectionBean.getIndivEdt());
        // 来源客户信息补录接口 最高学历
        reqYedCusToOnlineFinanceBean.setDgrCd(reqYedCustomerCollectionBean.getIndivDgr());
        // 来源客户信息补录接口 住宅性质
        reqYedCusToOnlineFinanceBean.setRsdntlTp(reqYedCustomerCollectionBean.getAddrNature());
        // 来源客户信息补录接口 家庭地址
        reqYedCusToOnlineFinanceBean.setFamAddr(reqYedCustomerCollectionBean.getIndivRsdAddr());
        // 来源客户信息补录接口 家庭邮编
        reqYedCusToOnlineFinanceBean.setFamPstcd(reqYedCustomerCollectionBean.getIndivZipCode());
        // 来源客户信息补录接口 邮箱
        reqYedCusToOnlineFinanceBean.setEmail(reqYedCustomerCollectionBean.getEmail());
        // 来源客户信息补录接口 行业代码
        reqYedCusToOnlineFinanceBean.setIndusCd(reqYedCustomerCollectionBean.getIndivComFld());
        // 来源客户信息补录接口 职业
        reqYedCusToOnlineFinanceBean.setCrrCd(reqYedCustomerCollectionBean.getIndivOcc());
        // 来源客户信息补录接口 职称
        reqYedCusToOnlineFinanceBean.setTtlCd(reqYedCustomerCollectionBean.getTitle());
        // 来源客户信息补录接口 职务
        reqYedCusToOnlineFinanceBean.setPosCd(reqYedCustomerCollectionBean.getIndivComJobTtl());
        // 来源客户信息补录接口 单位电话
        reqYedCusToOnlineFinanceBean.setWrkCorpTelNo(reqYedCustomerCollectionBean.getIndivComPhn());
        // 来源客户信息补录接口 邮编
        reqYedCusToOnlineFinanceBean.setPstcd(reqYedCustomerCollectionBean.getIndivZipCode());
        // 来源客户信息补录接口 紧急联系人姓名
        reqYedCusToOnlineFinanceBean.setUrgntCtcNm(reqYedCustomerCollectionBean.getEmergencyContactPerson());
        // 来源客户信息补录接口 紧急联系人电话
        reqYedCusToOnlineFinanceBean.setUrgntCtcTelNo(reqYedCustomerCollectionBean.getEmergencyContactPersonPhone());
        // 来源授信申请信息 产品编号10003001 个人短期税e贷 10003002 个人中长期税e贷  10001002普税贷
        reqYedCusToOnlineFinanceBean.setProdType(YedEnums.PrdIdEnum.YED.getValue());
        // 固定送值 非行员
        reqYedCusToOnlineFinanceBean.setOwnStfFlg(NO);
        //工作单位地址
        reqYedCusToOnlineFinanceBean.setWrkCorpAddr(reqYedCustomerCollectionBean.getIndivComAddr());
        return reqYedCusToOnlineFinanceBean;
    }

    /**
     * 更新本地 授信申请信息 授信申请联系人表 客人表信息 授信协议表 : <br>
     * <p>
     * 0.1:caoxin:2019/4/19 8:22: <br>
     *
     * @return
     * @author caoxin
     * @date 2019/4/19 8:22
     * @version 0.1
     * @since 2019/4/19 8:22
     */

    private void updateCustomerInfoOnCreditApplyAndCustomer(ReqYedCustomerCollectionBean reqYedCustomerCollectionBean) throws Exception {
        // 更新授信申请信息表
        updateCreditApplyInfo(reqYedCustomerCollectionBean);
        // 更新客人信息表
        updateCustomerInfo(reqYedCustomerCollectionBean);
        // 更新授信协议表信息表
        updateLmtProContInfo(reqYedCustomerCollectionBean);
        // 插入授信联系人表
        //insertCreditRelationInfo(reqYedCustomerCollectionBean);
        // 插入客人联系人表
        insertCustomerRelation(reqYedCustomerCollectionBean);
    }

    /**
     * 更新客人联系人表: <br>
     * <p>6
     * 0.1:caoxin:2019/4/24 10:40: <br>
     *
     * @return
     * @author caoxin
     * @date 2019/4/24 10:40
     * @version 0.1
     * @since 2019/4/24 10:40
     */

    private void insertCustomerRelation(ReqYedCustomerCollectionBean reqYedCustomerCollectionBean) throws Exception {
        CusIndivRelVO cusIndivRelVO = new CusIndivRelVO();
        // 主键
        cusIndivRelVO.setRelSerno(getCusId());
        // 来源客户信息补录接口 核心客户号
        cusIndivRelVO.setCusId(reqYedCustomerCollectionBean.getKeyCusNumber());
        // 来源客户信息补录接口 关联人姓名
        cusIndivRelVO.setRelName(reqYedCustomerCollectionBean.getEmergencyContactPerson());
        // 来源客户信息补录接口 关联人手机
        cusIndivRelVO.setMobile(reqYedCustomerCollectionBean.getEmergencyContactPersonPhone());
        // 来源客户信息补录接口 设置默认属性
        setServerUpdateDefaultProperty(cusIndivRelVO);
        int result = cusIndivRelService.insertCusIndivRel(cusIndivRelVO);
        if (result == -1) {
            throw new ESBException(EsbRetCodeStandard.SJCLYC.getValue(), "客户补录，插入客户关联人失败!!!");
        }

    }

    /**
     * 更新授信协议信息: <br>
     * <p>
     * 0.1:caoxin:2019/4/19 11:26: <br>
     *
     * @return
     * @author caoxin
     * @date 2019/4/19 11:26
     * @version 0.1
     * @since 2019/4/19 11:26
     */

    private void updateLmtProContInfo(ReqYedCustomerCollectionBean reqYedCustomerCollectionBean) throws ESBException {

        LmtPrdContVO lmtPrdContVO = Optional.ofNullable(lmtPrdContService.qryLmtPrdContByLmtApplySeq(reqYedCustomerCollectionBean.getLmtApplySeq())).orElseGet(LmtPrdContVO::new);
        // 来源客户信息补录接口 授信申请流水号
        lmtPrdContVO.setLmtApplySeq(reqYedCustomerCollectionBean.getLmtApplySeq());
        // 来源客户信息补录接口 核心客户号
        lmtPrdContVO.setCusId(reqYedCustomerCollectionBean.getKeyCusNumber());
        // 来源客户信息补录接口 客户姓名
        lmtPrdContVO.setCusName(reqYedCustomerCollectionBean.getCusName());
        // 来源客户信息补录接口 客户证件类型
        lmtPrdContVO.setCertType(reqYedCustomerCollectionBean.getCertTp());
        // 来源客户信息补录接口 身份证号码
        lmtPrdContVO.setCertCode(reqYedCustomerCollectionBean.getCertCode());
        //  来源客户信息补录接口 放款账户
        lmtPrdContVO.setRecvAccount(reqYedCustomerCollectionBean.getDistrCardNo());
        // 来源客户信息补录接口 还款账户
        lmtPrdContVO.setLoanAccount(reqYedCustomerCollectionBean.getRpyCardNo());
        // 来源客户信息补录接口 贷款用途
        lmtPrdContVO.setLoanUse(reqYedCustomerCollectionBean.getLoanUse());
        // 设置默认更新属性
        setServerUpdateDefaultProperty(lmtPrdContVO);
        int result = lmtPrdContService.updateByPk(lmtPrdContVO);
        if (result == -1) {
            throw new ESBException(EsbRetCodeStandard.SJCLYC.getValue(), "客户补录，更新额度信息失败!!!");
        }

    }

    /**
     * 更新授信联系人信息: <br>
     * <p>
     * 0.1:caoxin:2019/4/19 11:16: <br>
     *
     * @return
     * @author caoxin
     * @date 2019/4/19 11:16
     * @version 0.1
     * @since 2019/4/19 11:16
     */

    private void insertCreditRelationInfo(ReqYedCustomerCollectionBean reqYedCustomerCollectionBean) throws Exception {
        NlsApplyRelationVO nlsApplyRelationVO = new NlsApplyRelationVO();
        // 生成主键
        nlsApplyRelationVO.setRelApptSeq(getCusId());
        // 来源客户信息补录接口 设置授信申请流水号
        nlsApplyRelationVO.setApplySeq(reqYedCustomerCollectionBean.getLmtApplySeq());
        // 来源客户信息补录接口 设置关联客户ID
        nlsApplyRelationVO.setCusId(reqYedCustomerCollectionBean.getKeyCusNumber());
        // 来源客户信息补录接口 紧急联系人姓名
        nlsApplyRelationVO.setRelName(reqYedCustomerCollectionBean.getEmergencyContactPerson());
        // 来源客户信息补录接口 紧急联系人电话
        nlsApplyRelationVO.setRelMobile(reqYedCustomerCollectionBean.getEmergencyContactPersonPhone());
        // 设置默认值
        setServerInsertDefaultProperty(nlsApplyRelationVO);
        int result = nlsApplyRelationService.insertNlsApplyRelation(nlsApplyRelationVO);
        if (result == -1) {
            throw new ESBException(EsbRetCodeStandard.SJCLYC.getValue(), "客户补录,插入授信联系人信息失败!!!");
        }

    }

    /**
     * 更新客人表信息: <br>
     * <p>
     * 0.1:caoxin:2019/4/19 8:22: <br>
     *
     * @return
     * @author caoxin
     * @date 2019/4/19 8:22
     * @version 0.1
     * @since 2019/4/19 8:22
     */

    private void updateCustomerInfo(ReqYedCustomerCollectionBean reqYedCustomerCollectionBean) throws Exception {
        try {
            CusIndivVO cusIndivVO = new CusIndivVO();
            // 来源客户信息补录接口 cusId
            cusIndivVO.setCusId(reqYedCustomerCollectionBean.getKeyCusNumber());
            // 来源客户信息补录接口 客户姓名
            cusIndivVO.setCusName(reqYedCustomerCollectionBean.getCusName());
            // 来源客户信息补录接口 证件类型
            cusIndivVO.setCertType(reqYedCustomerCollectionBean.getCertTp());
            // 来源客户信息补录接口 客户号码
            cusIndivVO.setCertCode(reqYedCustomerCollectionBean.getCertCode());
            // 来源客户信息补录接口 证件到期日
            cusIndivVO.setIndivIdExpDt(reqYedCustomerCollectionBean.getIndivIdExpDt());
            // 来源客户信息补录接口 证件到期日
            cusIndivVO.setIndivMarSt(reqYedCustomerCollectionBean.getIndivMarSt());
            // 来源客户信息补录接口 最高学历
            cusIndivVO.setIndivEdt(reqYedCustomerCollectionBean.getIndivEdt());
            // 来源客户信息补录接口 最高学位
            cusIndivVO.setIndivDgr(reqYedCustomerCollectionBean.getIndivDgr());
            // 来源客户信息补录接口 家庭地址
            cusIndivVO.setFamilyAddr(reqYedCustomerCollectionBean.getIndivRsdAddr());
            // 来源客户信息补录接口 邮件编码
            cusIndivVO.setPostCode(reqYedCustomerCollectionBean.getIndivZipCode());
            // 来源客户信息补录接口 手机
            cusIndivVO.setPhone(reqYedCustomerCollectionBean.getPhone());
            // 来源客户信息补录接口 emal地址
            cusIndivVO.setEmail(reqYedCustomerCollectionBean.getEmail());
            // 来源客户信息补录接口 单位所属行业
            cusIndivVO.setIndivComFld(reqYedCustomerCollectionBean.getIndivComFld());
            // 来源客户信息补录接口 从事职业
            cusIndivVO.setIndivOcc(SDicToLocal.getLocalSysDicVal(SDicToLocalConstant.CRR,reqYedCustomerCollectionBean.getIndivOcc()));
            // 来源客户信息补录接口 单位电话
            cusIndivVO.setIndivComPhn(reqYedCustomerCollectionBean.getIndivComPhn());
            // 单位电话
            cusIndivVO.setIndivComAddr(reqYedCustomerCollectionBean.getIndivComAddr());
            // 来源客户信息补录接口 职务
            cusIndivVO.setIndivComJobTtl(reqYedCustomerCollectionBean.getIndivComJobTtl());
            // 来源客户信息补录接口 职称
            cusIndivVO.setIndivCrtfctn(reqYedCustomerCollectionBean.getTitle());
            // 来源客户信息补录接口 住宅性质
            cusIndivVO.setAddrNature(reqYedCustomerCollectionBean.getAddrNature());
            // 设置默认更新
            setServerUpdateDefaultProperty(cusIndivVO);
            int result = cusIndivService.updateByPk(cusIndivVO);
            if (result == -1) {
                throw new ESBException(EsbRetCodeStandard.SJCLYC.getValue(), "客户补录，更新客户信息失败!!!");
            }
        } catch (Exception e) {
            throw new ESBException(EsbRetCodeStandard.SJCLYC.getValue(), "客户补录，更新客户信息转换字典项失败!!!");
        }

    }

    /**
     * 更新授信表信息: <br>
     * <p>
     * 0.1:caoxin:2019/4/19 8:23: <br>
     *
     * @return
     * @author caoxin
     * @date 2019/4/19 8:23
     * @version 0.1
     * @since 2019/4/19 8:23
     */

    private void updateCreditApplyInfo(ReqYedCustomerCollectionBean reqYedCustomerCollectionBean) throws ESBException {
        NlsCreditInfoVO nlsCreditInfoVO = new NlsCreditInfoVO();
        // 来源客户信息补录接口 客户ID
        nlsCreditInfoVO.setCusId(reqYedCustomerCollectionBean.getKeyCusNumber());
        // 来源客户信息补录接口 授信申请流水号
        nlsCreditInfoVO.setLmtApplySeq(reqYedCustomerCollectionBean.getLmtApplySeq());
        // 来源客户信息补录接口 还款卡号
        //nlsCreditInfoVO.setRecvAccount(reqYedCustomerCollectionBean.getRpyCardNo());
        // 来源客户信息补录接口 放款卡号
        //nlsCreditInfoVO.setDnAccount(reqYedCustomerCollectionBean.getDistrCardNo());
        // 来源客户信息补录接口 证件有效期
        nlsCreditInfoVO.setCertEndDt(reqYedCustomerCollectionBean.getIndivIdExpDt());
        // 来源客户信息补录接口 从事职业
        nlsCreditInfoVO.setProfession(reqYedCustomerCollectionBean.getIndivOcc());
        // 来源客户信息补录接口 联系地址
        nlsCreditInfoVO.setIndivRsdAddr(reqYedCustomerCollectionBean.getIndivRsdAddr());
        // 来源客户信息补录接口 学历
        nlsCreditInfoVO.setEdu(reqYedCustomerCollectionBean.getIndivEdt());
        // 来源客户信息补录接口 单位电话
        nlsCreditInfoVO.setWrkCorpMobile(reqYedCustomerCollectionBean.getIndivComPhn());
        // 来源客户信息补录接口 婚姻状况
        nlsCreditInfoVO.setMrgSitu(reqYedCustomerCollectionBean.getIndivMarSt());
        // 来源客户信息补录接口 职称
        nlsCreditInfoVO.setTtl(reqYedCustomerCollectionBean.getTitle());
        // 来源客户信息补录接口 最高学位
        nlsCreditInfoVO.setIndivDgr(reqYedCustomerCollectionBean.getIndivDgr());
        // 来源客户信息补录接口 住宅性质
        nlsCreditInfoVO.setAddrNature(reqYedCustomerCollectionBean.getAddrNature());
        // 来源客户信息补录接口 邮政编码
        nlsCreditInfoVO.setPostCode(reqYedCustomerCollectionBean.getIndivZipCode());
        // 来源客户信息补录接口 Email
        nlsCreditInfoVO.setEmail(reqYedCustomerCollectionBean.getEmail());
        // 来源客户信息补录接口 行业
        nlsCreditInfoVO.setIndivComFld(reqYedCustomerCollectionBean.getIndivComFld());
        // 来源客户信息补录接口 职务
        nlsCreditInfoVO.setIndivComJobTtl(reqYedCustomerCollectionBean.getIndivComJobTtl());
        // 来源客户信息补录接口 手机
        nlsCreditInfoVO.setIndivMobile(reqYedCustomerCollectionBean.getPhone());
        // 来源客户信息补录接口 手机
        nlsCreditInfoVO.setLoanUseType(reqYedCustomerCollectionBean.getLoanUse());
        // 设置默认更新属性
        setServerUpdateDefaultProperty(nlsCreditInfoVO);
        int result = nlsCreditInfoService.updateByPk(nlsCreditInfoVO);
        if (result == -1) {
            throw new ESBException(EsbRetCodeStandard.SJCLYC.getValue(), "客人补录,更新授信信息失败!!!");
        }
    }
    /**
     * 生成客户ID: <br>
     * 0.1:caoxin:2019/6/24 19:21: <br>
     * @author caoxin
     * @return
     * @since 2019/6/24 19:21
     * @date 2019/6/24 19:21
     * @version 0.1
     */
    public String getCusId() throws Exception {
        SequenceService sequenceService = (SequenceService) SpringContextUtils.getBean("dbSeqService");
        return sequenceService.getSequence("CUS_REL_SERNO", null, null);
    }



    /**
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(YedNlsCustomerProcessService.class);
    /**
     * 日志模板
     */
    private final String msgTemplate = "message{}";

    /**
     * 客人信息服务
     */
    @Autowired
    @Qualifier("cusIndivService")
    private CusIndivService cusIndivService;

    /**
     * 授信申请服务
     */
    @Autowired
    @Qualifier("nlsCreditInfoService")
    private NlsCreditInfoService nlsCreditInfoService;

    /**
     * 授信联系人服务
     */
    @Autowired
    @Qualifier("nlsApplyRelationService")
    private NlsApplyRelationService nlsApplyRelationService;

    /**
     * 授信协议表服务
     */
    @Autowired
    @Qualifier("lmtPrdContService")
    private LmtPrdContService lmtPrdContService;
    /**
     * 客户关联人服务
     */
    @Autowired
    @Qualifier("cusIndivRelService")
    private CusIndivRelService cusIndivRelService;

    /**
     * 客户信息补录服务
     */
    @Autowired
    @Qualifier("yedCustomerCollectionService")
    private YedCustomerCollectionService yedCustomerCollectionService;

    /** 默认赋值*/
    private static final String PRODTYPE = "10003001";
    /** 非行员标志*/
    final String NO = "0";
}
